package practice.library.gremlin_scala.trial.friends_group.model

import gremlin.scala.{label, _}
import org.joda.time.DateTime

import scala.util.{Failure, Success, Try}

/**
  * Created by lovepocky on 16/7/18.
  */
object Edge {

	object label {
		val friends = "friends"
		val writeBy = "writeBy"
		//val hotel = "hotel"
		//val shopping = "shopping"

		val pointer_readBy = "pointer_readBy"
	}

	def transform2CC(edge: Edge): Try[_] = {
		edge.label() match {
			case label.`friends` => Success(edge.toCC[friends])
			case label.`writeBy` => Success(edge.toCC[writeBy])
			//case label.hotel => Success(vertex.toCC[hotel])
			//case label.shopping => Success(vertex.toCC[shopping])
			case _ => Failure(new Exception("label not match"))
		}
	}

	@label(label.friends)
	case class friends(updateTime: DateTime = DateTime.now())

	@label(label.writeBy)
	case class writeBy(updateTime: DateTime = DateTime.now())


	/** Index Edge */
	@label(label.pointer_readBy)
	case class pointerReadBy()
}
